<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | 王勇程 <laughskydragon@qq.com>                         |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\api\controller;

/**
 * 公共基础接口控制器
 */
class Common extends ApiBase
{
    /**
     * 友情链接
     */
    public function getBlogrollList()
    {
        return $this->apiReturn($this->logicCommon->getBlogrollList());
    }

    /**
     * 发送验证码
     */
    public function sendVerificationCode()
    {
        $data = $this->filterApiParams(['mobile', 'type']);
        
        return $this->apiReturn($this->logicCommon->sendVerificationCode($data));
    }

    /**
     * 过滤API参数
     */
    private function filterApiParams($fields = [])
    {
        $data = [];
        foreach ($fields as $field) {
            $value = $this->request->param($field);
            if ($value !== null) {
                $data[$field] = $value;
            }
        }
        return $data;
    }
}
